<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/inc/sessionCheck.jsp" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display"%>
<%@ taglib uri="/WEB-INF/config/tld/fmt.tld" prefix="fmt"%>
<%@ taglib uri="http://ssh.org/selects" prefix="ssh"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
	String applicationPath = basePath + "/" + "application";
	String roleName = request.getAttribute("RoleName")==null?null:request.getAttribute("RoleName").toString();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>
		<link href="<%=path%>/css/jinmu_style.css" rel="stylesheet" type="text/css" />
		<script language="javascript" src="<%=path%>/js/util.js"></script>
		<script language="javascript" src="<%=path%>/js/frame.js"></script>
		<style type="text/css">

			table.simple thead tr th {
				background-color: #EEF1FB;
			}
			
			table.simple tr.even {
				background-color: #fff;
			}
			
			table.simple {
				border: 1px solid #BAC8EF;
				border-collapse: collapse;
			}
			
			table.simple td,table.simple th {
				border: 1px solid #BAC8EF;
			}
			
			.pagelinks{
				width: 100%;
				display: block;
				border-top: none;
				margin-bottom: -5px;
				text-align:right;
				margin:0 auto;
				font-size: 12px;
			}
		</style>
	</head>
	<body>
	 <html:form styleId="projectrfpsForm"
			action="listProjectApproval.do?method=getProjectApprovalList">
		<table cellspacing="0" cellpadding="0" width="98%" align="center"  border="0" class="margtb5">
		    <tr>
		      <td align="left" class="padl5 lan12"><img src="<%=path%>/images/img-11.gif" width="12" height="12">&nbsp;项目管理 &gt; 立项管理 &gt; 立项信息</td>
		    </tr>
		</table>
				<table cellspacing="3" cellpadding="0" width="98%" align="center"  border="0" class="kuang2 margtb5 hei12">
							<tr>
								<td width="11%" align="right">
									<bean:message
										key="com.application.projectrfps.entity.projectrfps.listpage.projectname"
										bundle="projectrfps" />
									：
								</td>
								<td width="21%">
									<html:text property="projectname" style="width:178px;"/>
								</td>

								<td width="14%" align="right">
									<bean:message
										key="com.application.projectrfps.entity.projectrfps.listpage.departname"
										bundle="projectrfps" />
									：
								</td>
								<td width="21%">
									<html:text property="departname" />
								</td>

								<td width="12%" align="right">
									<bean:message
										key="com.application.projectrfps.entity.projectrfps.listpage.principal"
										bundle="projectrfps" />
									：
								</td>
								<td width="21%">
									<html:text property="principal" />
								</td>
							</tr>

							<tr>
								<td align="right">
									<bean:message
										key="com.application.projectrfps.entity.projectrfps.listpage.state"
										bundle="projectrfps" />
									：
								</td>
								<td>
									<ssh:select propertyName="state" defaultName="${projectrfpsForm.state}" pid="projectApproval_type" type="1"/>
								</td>
								<td align="right">
									<bean:message
										key="com.application.projectrfps.entity.projectrfps.listpage.year"
										bundle="projectrfps" />
									：
								</td>
								<td width="15%">


									  <html:select property="year">
									  <option value="">----请选择----</option>
	                      	 <c:forEach var="i" begin="2005" end="2050" step="1"> 
	                      	       
                                   <c:if test="${projectrfpsForm.year==i }">
                                   		<option value="<c:out value="${i}" />" selected>${i}</option>
                                   </c:if>
                                   <c:if test="${projectrfpsForm.year!=i }">
                                   		<option value="<c:out value="${i}" />" >${i}</option>
                                   </c:if>
                               </c:forEach>
	                      </html:select>
								</td>
								<td align="right" class="padr10">
									<input id="but_query" type="button" class="buttonbg"
										value="<bean:message key='com.syc.common.projectrfps.query'  bundle="projectrfps"/>"
										name="but_query" onClick="query();" />
								</td>
						</tr>
			</table>


<table cellspacing="0" cellpadding="0" width="98%" align="center"  border="0" class="margb5">
<tr>

        <td colspan="8" class="bgcolor2 padlr5">
    		<table border="0" cellspacing="0" cellpadding="0" class="lan13b">
	      <tr>
	         <% if(roleName!=null && (roleName.equals("科研项目主管") || roleName.equals("科研项目管理员"))){
   %>
   
		  <td width="25" align="center"><img src="<%=applicationPath%>/images/tianjia.gif" alt="<bean:message key='com.syc.common.projectrfps.add' bundle="projectrfps"/>" height="15" width="15" /></td>
		  <td class="lieb-zi" width="40"><a href="#" onClick="addProjectrfps();" ><bean:message key='com.syc.common.projectrfps.add' bundle="projectrfps"/></a></td>

		  <td width="25" align="center"><img src="<%=applicationPath%>/images/bianji.gif" alt="<bean:message key='com.syc.common.projectrfps.modify' bundle="projectrfps"/>" height="15" width="15" /></td>
		  <td class="lieb-zi"  width="40"><a href="#" onClick="modifyProjectRfps();" ><bean:message key='com.syc.common.projectrfps.modify' bundle="projectrfps"/></a></td>

		  <td width="25" align="center"><img src="<%=applicationPath%>/images/shanchu.gif" alt="<bean:message key='com.syc.common.projectrfps.del' bundle="projectrfps"/>" height="15" width="15" /></td>
		  <td class="lieb-zi"  width="40"><a href="#" onClick="del();" ><bean:message key='com.syc.common.projectrfps.del' bundle="projectrfps"/></a></td>

             <%
       }
   %>
		  <td width="25" align="center"><img src="<%=applicationPath%>/images/chakan.gif" alt="<bean:message key='com.syc.common.projectrfps.view' bundle="projectrfps"/>" height="15" width="15"/></td>
		  <td width="40" class="lieb-zi"><a href="#" onClick="view();"><bean:message key='com.syc.common.projectrfps.view' bundle="projectrfps"/></a></td>
		  <td class="lieb-zi">&nbsp;</td>
	       </tr>
	      </table> 
	      
	</td>
	</tr>
 
				<tr>
					<td>
						<fmt:bundle
							basename="com.application.projectrfps.struts.ApplicationResources_projectrfps">
							<display:table name="projectrfpsList" class="simple"
								id="projectrfpss" pagesize="10" partialList="true"
								 defaultorder="descending" size="resultSize"
								requestURI="listProjectApproval.do?method=getProjectApprovalList">
								
    							<display:column title="选择"
									sortable="false" 
									style=" width:5%; text-align:center;">
							   
							      <input type="checkbox" name="id" value="${projectrfpss.id},${projectrfpss.worksheetstate},${projectrfpss.procid}" />
							    </display:column>
			<display:column style=" width:8%; text-align:center;"
									titleKey="com.application.projectworksheets.entity.projectworksheets.listpage.projectid"
									sortable="true">
									<a onclick="viewProjectWorkSheets('${projectrfpss.worksheetsid}');" href="#" >${projectrfpss.projectID}</a> 
									</display:column>
                                
             <display:column titleKey="com.application.projectrfps.entity.projectrfps.listpage.projectname" sortable="true" style="width:15%; text-align:center;">
                   <a onclick="viewProjectrfps('${projectrfpss.id}');" href="#" >${projectrfpss.projectname}</a> 
              </display:column>
                                
								<display:column property="departname"  style=" width:10%; text-align:center;"
									titleKey="com.application.projectrfps.entity.projectrfps.listpage.departname"
									sortable="true"/>


								<display:column property="principal"  style=" width:10%; text-align:center; "
									titleKey="com.application.projectrfps.entity.projectrfps.listpage.principal"
									sortable="true"/>



								<display:column property="year"  style=" width:5%; text-align:center;"
									titleKey="com.application.projectrfps.entity.projectrfps.listpage.year"
									sortable="true"/>
									
								<display:column property="state"  style=" width:10%; text-align:center;"
									titleKey="com.application.projectrfps.entity.projectrfps.listpage.state" 
									sortable="true" headerClass="ctitle" decorator="com.sync.commons.DictCodeColumnDecorator" dictCode="projectApproval_type"/>	
								
									         <% if(roleName!=null && (roleName.equals("科研项目主管") || roleName.equals("科研项目管理员"))){
   %>
							   <display:column title="修改状态" style=" width:8%; text-align: center;">
						
											<a href="#" onclick="modifyState('<bean:write name="projectrfpss" property="id"/>');">
												<img style="cursor:hand;" src="${pageContext.request.contextPath}/application/images/modifystate.gif" border="0" alt="修改状态">
											</a>				
										
								</display:column>									
							   <display:column title="修改任务书" style=" width:8%; text-align: center;">
										<c:choose>
										<c:when test="${projectrfpss.worksheetstate!=42003}">
											<a href="#">
												<img style="FILTER:gray"  src="${pageContext.request.contextPath}/application/images/modifystate.gif" border="0" alt="不可修改">
											</a>				
										</c:when>
										<c:otherwise>
												<img style="cursor:hand;" src="${pageContext.request.contextPath}/application/images/modifystate.gif" border="0" onclick="modifyProjectWorkSheet('${projectrfpss.worksheetsid}');" alt="修改">
										</c:otherwise>
									</c:choose>
								</display:column>		
								             <%
       }
   %>			
							</display:table>
						</fmt:bundle>
					</td>
				</tr>
			</table>
			<input type="hidden" id="totalPage" value="${totalPage}"/>
		</html:form>
	</body>
</html>
<script>
function query(){
	document.forms[0].action="listProjectApproval.do?method=getProjectApprovalList";
	document.forms[0].submit();
}

//新增
function addProjectrfps(){
    document.forms[0].action="toAddProjectrfps.do?method=toAddProjectrfps&fromModel=approval";
	document.forms[0].submit();
}


function modifyState(id){
    var url ="enterProjectApprovalModifyState.do?method=enterProjectApprovalModifyState&id=" + id;
	var returnValue = showDialog(url);
	if(returnValue == 1){
	    window.location.reload();
	}
}

//修改建议书
function modifyProjectRfps(){
    var result = validateSelect();
	if(result==0){
		alert("请选择一条记录！");
		return;
	}else if(result>1){
	    alert("一次只能修改一条记录！");
		return;
	}else{
		document.forms[0].action="toUpdateProjectrfps.do?method=toUpdateProjectrfps&fromModel=approval";
	    document.forms[0].submit();
	}
	
}

function modifyProjectWorkSheet(workSheetsID){

  	document.forms[0].action="toUpdateProjectworksheets.do?method=toUpdateProjectworksheets&fromModel=approval&id=" + workSheetsID;
  	//document.forms[0].action="application/projectworksheets/toUpdateInc.do?method=toUpdateInc&id=" + workSheetsID;
	document.forms[0].submit();
}	
	
function validateSelect(){ 
    var count = 0;
    var jysBox = $s("id");
    for(var i=0;i<jysBox.length;i++){
		if(jysBox[i].checked){
        	count++;
		}
	}
    return count;
}


function view(){
	var result = validateSelect();
	if(result==0){
		alert("请选择一条记录！");
		return;
	}else if(result>1){
	    alert("一次只能查看一条记录！");
		return;
	}else{
	    var id = getSelectedIds('id');
		viewProjectrfps(id);
	}
}

//全选   
function checkAll()   
{ 
  
   var chk=document.getElementsByName("selectId");   
   for(var i=0;i<chk.length;i++)   
   { 
     if($('checkall').checked){
     	chk(i).checked=true; 
     }else{
        chk(i).checked=false; 
     } 
       
 }
  
}   


function viewProjectrfps(id){
   document.forms[0].action="viewProjectrfps.do?method=viewProjectrfps&fromModel=approval&id=" + id;
   document.forms[0].submit();
}

function viewProjectWorkSheets(id){
   document.forms[0].action="viewProjectworksheets.do?method=viewProjectworksheets&id=" + id;
   document.forms[0].submit();
}

function del(){
    var result = validateSelect();
	if(result==0)
	{
		alert("请选择一条记录！");
		return false;
	}else if(result>1){
	    alert("请选择一条记录！");
		return;
	}else{
	    var ids = getSelectedIds('id');
	    var idArry = ids.split(",");
	    var rfpsid = idArry[0];
	    var worksheetstate = idArry[1]==""||idArry[1]==null?false:idArry[1];
	    var procid = idArry[2]==""||idArry[2]==null?false:idArry[2];
	    if((!worksheetstate || worksheetstate =='42001' ) && procid == 0 ){
	       if(confirm("是否要删除所选的信息？")){
	       	   document.forms[0].action="deleteApproval.do?method=deleteApproval&id=" + rfpsid;
	           document.forms[0].submit(); 
	       }

	    }else{
	       alert("该记录不能删除！");
	    }
	}
}
</script>
